home *** CD-ROM | disk | FTP | other *** search
Text File | 1990-10-05 | 2.8 KB | 88 lines | [TEXT/MPS ] |
- #
- # File: SomeFinderOperations.vu
- #
- # Contains: Tasks that help do some simple Finder operations like
- # Selecting a file in a window, Trashing it.
- #
- # Written by: P Nagarajan
- #
- # Copyright: © 1990 by Apple Computer, Inc., all rights reserved.
- #
- # Change History:
- #
- # 11/7/89 naga creation
- #
- # To Do:
- #
-
- # *****************************************************************************************
- task Find_object_in_window (at_x, at_y)
- #this task moves the mouse on to a particular object of interest. Very useful to select
- #files in "view by name" mode in Finder.
- #this assumes that the file/icon/object you want to select is on the frontmost window
- # with coordinates (at_x, at_y) relative to the window's origin
- begin
- match [window o:1 r:?rect]!;
- file_x := rect[1] + at_x;
- file_y := rect[2] + at_y;
- move a:{file_x, file_y};
- end;#Find_object_in_window
-
-
- # *****************************************************************************************
- task check_for_alert_window(override_alerts := false)
- #handles alert dialogs with 'OK' and 'Cancel' buttons.
- #if override_alerts is true then select 'OK' else 'Cancel'
- begin
- if(match[button w:[window ord:1 style:dialog] t:'OK']!) begin
- text_messages := collect[staticText w:[window ord:1 style:dialog]]!;
- println "dismissing dialog that came up after resource type selection -- static text messages follow:";
- for each m in text_messages println " ∂t",m.t;
- if override_alerts select [button t:'OK' w:[window ord:1 style:dialog]]!;
- else select [button t:'Cancel' w:[window ord:1 style:dialog]]!;
- end;#if dialog appeared
- end;#check_for_alert_window
-
-
- # *****************************************************************************************
- task throw_trash(print_any_error := true, override_alerts := false)
- # this task trashes a specified object in Finder.
- # task assumes that the mouse is already positioned on the item to be trashed
- # and that the trash can is positioned on the main screen at (-40,-40) relative to
- # the lower right corner.
- # Arguements: 'print_any_error' can be used to suppress error messages and
- # 'override_alerts' can be used to trash despite alerts.
- begin
- PressMouse;
- match [screen r:?rect m:true]!;
- if rect
- begin
- trash_x := rect[3] - 40;
- trash_y := rect[4] - 40;
- move a:{trash_x, trash_y};
- #move a:{472, 301};#trash can on a SE
- ReleaseMouse;
- check_for_alert_window(override_alerts);
- if match [menuItem t:'Empty Trash' m:'Special' e:true]!
- select [menuItem t:'Empty Trash' m:'Special']!;
- else
- begin
- if print_any_error
- println "Empty Trash menu item not enabled, could not trash…";
- return false;
- end;
- end;#if unified correctly
- else
- begin
- if print_any_error
- println "Unable to find trash can, could not trash…";
- return false;
- end;
- return true;
- end; #throw_trash
-
-
- (* Example Usage:
- Find_object_in_window( 9, 46); #first file
- throw_trash();
- *)